#-*-coding:utf-8-*-
import requests
import time

# 请求头
headers = {'content-type': 'application/x-www-form-urlencoded;charset=UTF-8'}
text = "亲，宿舍电费不足，请尽快充值！【家园工作室】"  # 要发送的短信内容
url = "http://www.jianzhou.sh.cn/JianzhouSMSWSServer/http/sendBatchMessage"

account = "sdk_ndxgc"
password = "jianzhou"


def send_sms(mobile):
    """
    智能匹配模板发送
    参数为接收者手机号（字符串），多个则使用分号隔开
    """
    rawtime = time.strftime("%Y%m%d%X", time.localtime())
    localtime = "".join(rawtime.split(":"))  # 14位当地时间
    params = {'account': account, 'password': password,
              'destmobile': mobile, "msgText": text, "sendDateTime": localtime}  # 参数
    response = requests.post(url, data=params, headers=headers, timeout=10)
    return response.text
